package com.gr.jron.model;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by IntelliJ IDEA.
 * User: jron
 * Date: 2007-6-13
 * Time: 10:40:11
 * It's jron's dream to cqiu
 */
@Entity
@Table(name = "JIMAGE")
public class Jimage extends BaseObject {

    private Long id;

    private String name;
    private String newName;
    private String path;
    private Long size;
    private Date uploadTime;
    private boolean selected;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    public Long getId() {
        return id;
    }

    public String getName() {
        return name;
    }

    public String getNewName() {
        return newName;
    }

    public Long getSize() {
        return size;
    }

    public Date getUploadTime() {
        return uploadTime;
    }

    public boolean isSelected() {
        return selected;
    }

    @Column(nullable = false)
    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setNewName(String newName) {
        this.newName = newName;
    }

    public void setSize(Long size) {
        this.size = size;
    }

    public void setUploadTime(Date uploadTime) {
        this.uploadTime = uploadTime;
    }

    public void setSelected(boolean selected) {
        this.selected = selected;
    }


    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        Jimage jimage = (Jimage) o;

        return selected == jimage.selected
                && !(size != null ? !size.equals(jimage.size) : jimage.size != null)
                && !(uploadTime != null ? !uploadTime.equals(jimage.uploadTime) : jimage.uploadTime != null);
    }

    public int hashCode() {
        int result;
        result = (size != null ? size.hashCode() : 0);
        result = 31 * result + (uploadTime != null ? uploadTime.hashCode() : 0);
        result = 31 * result + (selected ? 1 : 0);
        return result;
    }


    public String toString() {
        return "Jimage{" +
                "name='" + name + '\'' +
                ", newName='" + newName + '\'' +
                ", size=" + size +
                ", uploadTime='" + uploadTime + '\'' +
                ", selected=" + selected +
                '}';
    }
}
